﻿using System;
using System.Collections;

namespace _2.求一个整数数组的最大值_最小值_平均值和所有数组元素的和
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数组：");
            string numsStr = Console.ReadLine();
            int cur = 0, numsLen = 0, numsSum = 0, numsMax = 0, numsMin = 0x3f3f3f3f;
            ArrayList nums = new ArrayList();
            while (cur < numsStr.Length)
            {
                int num = 0;
                bool isNum = false;
                while (cur < numsStr.Length && '0' <= numsStr[cur] && numsStr[cur] <= '9')
                {
                    isNum = true;
                    num = num * 10 + numsStr[cur] - '0';
                    cur += 1;
                }
                if (isNum)
                {
                    numsLen += 1;
                    numsSum += num;
                    numsMax = Math.Max(numsMax, num);
                    numsMin = Math.Min(numsMin, num);
                }
                cur += 1;
            }

            double numsAver = (numsSum * 1.0) / numsLen;
            Console.WriteLine("数组的最大值为：" + numsMax);
            Console.WriteLine("数组的最小值为：" + numsMin);
            Console.WriteLine("数组的平均值为：{0:0.###}", numsAver);
            Console.WriteLine("数组的和为：" + numsSum);

        }
    }
}
